package com.bruan.d6_DateTimeFormatter;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Test {
    public static void main(String[] args) {
        //绑定格式
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        //格式化
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        System.out.println(dateTimeFormatter.format(now));

        String localDateTime = "2022-11-22 12:21:33";
        LocalDateTime ldt = LocalDateTime.parse(localDateTime,dateTimeFormatter);
        System.out.println(ldt);
    }
}
